package com.mmy.fta.trade.web.rest;


import com.mmy.fta.cargo.api.model.CargoInfoDTO;
import com.mmy.fta.trade.server.dto.CanceledOrderDTO;
import com.mmy.fta.trade.server.dto.CompletedOrderDTO;
import com.mmy.fta.trade.server.dto.TransportOrderDTO;
import com.mmy.fta.trade.server.request.AgreeOrderRequest;
import com.mmy.fta.trade.server.request.CancelOrderRequest;
import com.mmy.fta.trade.server.request.CanceledOrderRequest;
import com.mmy.fta.trade.server.request.ColdTruckRequest;
import com.mmy.fta.trade.server.request.CompletedOrderRequest;
import com.mmy.fta.trade.server.request.LoadOrderRequest;
import com.mmy.fta.trade.server.request.PrePayCargoFeeRequest;
import com.mmy.fta.trade.server.request.PrePayDepositRequest;
import com.mmy.fta.trade.server.request.RefuseOrderRequest;
import com.mmy.fta.trade.server.request.RepublishCargoRequest;
import com.mmy.fta.trade.server.request.TransportOrderRequest;
import com.mmy.fta.trade.server.request.PreCreatOrderRequest;
import com.mmy.fta.trade.server.request.UnloadOrderRequest;
import com.mmy.fta.trade.server.response.ColdTruckResponse;
import com.mmy.fta.trade.server.response.PreCreatOrderResponse;
import com.mmy.fta.trade.server.response.PrePayCargoFeeResponse;
import com.mmy.fta.trade.server.response.PrePayDepositResponse;
import com.mmy.fta.trade.server.service.OrderService;
import com.mmy.fta.trade.server.service.PaymentService;
import com.mmy.fta.trade.web.request.AgreeOrderWebRequest;
import com.mmy.fta.trade.web.request.AppraiseOrderWebRequest;
import com.mmy.fta.trade.web.request.CancelOrderWebRequest;
import com.mmy.fta.trade.web.request.CanceledOrderWebRequest;
import com.mmy.fta.trade.web.request.ColdTruckWebRequest;
import com.mmy.fta.trade.web.request.CompletedOrderWebRequest;
import com.mmy.fta.trade.web.request.LoadOrderWebRequest;
import com.mmy.fta.trade.web.request.PrePayCargoFeeWebRequest;
import com.mmy.fta.trade.web.request.PrePayDepositWebRequest;
import com.mmy.fta.trade.web.request.RefuseOrderWebRequest;
import com.mmy.fta.trade.web.request.RepublishCargoWebRequest;
import com.mmy.fta.trade.web.request.TransportOrderWebRequest;
import com.mmy.fta.trade.web.request.PreCreatOrderWebRequest;
import com.mmy.fta.trade.web.request.UnloadOrderWebRequest;
import com.mmy.fta.trade.web.response.AppraiseOrderWebResponse;
import com.mmy.fta.trade.web.response.CanceledOrderWebResponse;
import com.mmy.fta.trade.web.response.ColdTruckWebResponse;
import com.mmy.fta.trade.web.response.CompletedOrderWebResponse;
import com.mmy.fta.trade.web.response.PrePayCargoFeeWebResponse;
import com.mmy.fta.trade.web.response.PrePayDepositWebResponse;
import com.mmy.fta.trade.web.response.RepublishCargoWebResponse;
import com.mmy.fta.trade.web.response.TransportOrderWebResponse;
import com.mmy.fta.trade.web.response.PreCreatOrderWebResponse;
import com.ymm.common.web.BaseData;
import com.ymm.common.web.YmmResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @apiNote 订单入口
 * @author qiang.lin
 * @since 2021/10/20
 */
@RestController
@RequestMapping(value = "/order")
@Slf4j
public class OrderController {

    @Autowired
    OrderService orderService;

    @Autowired
    PaymentService paymentService;

    /**
     * 司机-点击 立即抢单-preCreatOrder
     * @param preCreatOrderWebRequest
     * @return
     */
    @PostMapping(value = "driver/preCreatOrder")
    public YmmResponse<PreCreatOrderWebResponse> preCreatOrderByDriver(@RequestBody PreCreatOrderWebRequest preCreatOrderWebRequest){
        if(preCreatOrderWebRequest == null || preCreatOrderWebRequest.getCargoId() == null || preCreatOrderWebRequest.getOpenId() == null ){
            log.info("preCreatOrderWebRequest 参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }

        PreCreatOrderRequest preCreatOrderRequest = new PreCreatOrderRequest();
        BeanUtils.copyProperties(preCreatOrderWebRequest,preCreatOrderRequest);

        PreCreatOrderResponse preCreatOrderResponse = orderService.preCreateOrder(preCreatOrderRequest);

        PreCreatOrderWebResponse preCreatOrderWebResponse = new PreCreatOrderWebResponse();
        BeanUtils.copyProperties(preCreatOrderResponse,preCreatOrderWebResponse);
        preCreatOrderWebResponse.setOpenId(preCreatOrderWebRequest.getOpenId());

        try {
            log.info("司机-立即抢单-正常：{}", preCreatOrderWebResponse.toString());
            return YmmResponse.succResponse(preCreatOrderWebResponse);
        } catch (Exception e) {
            e.printStackTrace();
            log.info("司机-立即抢单-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }



    /**
     * 司机-支付订金页面-prePayDeposit
     * @param preCreatOrderWebRequest
     * @return
     */
    @PostMapping(value = "driver/prePayDeposit")
    public YmmResponse<PrePayDepositWebResponse> prePayDepositByDriver(@RequestBody PrePayDepositWebRequest preCreatOrderWebRequest){
        if(preCreatOrderWebRequest == null || preCreatOrderWebRequest.getCargoId() == null || preCreatOrderWebRequest.getOpenId() == null ){
            log.info("preCreatOrderWebRequest 参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }

        PrePayDepositRequest prePayDepositRequest = new PrePayDepositRequest();
        BeanUtils.copyProperties(preCreatOrderWebRequest,prePayDepositRequest);

        PrePayDepositResponse prePayDepositByDriver = paymentService.prePayDepositByDriver(prePayDepositRequest);

        PrePayDepositWebResponse payDepositWebResponse = new PrePayDepositWebResponse();
        BeanUtils.copyProperties(prePayDepositByDriver,payDepositWebResponse);


        try {
            log.info("司机-立即抢单-正常：{}", prePayDepositByDriver.toString());
            return YmmResponse.succResponse(payDepositWebResponse);
        } catch (Exception e) {
            e.printStackTrace();
            log.info("司机-立即抢单-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }

    /**
     * 货主-点确认收货-prePayCargoFee
     * @param prePayCargoFeeWebRequest
     * @return
     */
    @PostMapping(value = "shipper/prePayCargoFee")
    public YmmResponse<PrePayCargoFeeWebResponse> prePayCargoFeeByShipper(@RequestBody PrePayCargoFeeWebRequest prePayCargoFeeWebRequest){
        if(prePayCargoFeeWebRequest == null || prePayCargoFeeWebRequest.getOrderNumber() == null || prePayCargoFeeWebRequest.getOpenId() == null ){
            log.info("preCreatOrderWebRequest 参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }

        PrePayCargoFeeRequest payCargoFeeRequest =new PrePayCargoFeeRequest();

        BeanUtils.copyProperties(prePayCargoFeeWebRequest,payCargoFeeRequest);

        PrePayCargoFeeResponse prePayCargoFeeResponse = paymentService.prePayCargoFeeByShipper(payCargoFeeRequest);

        PrePayCargoFeeWebResponse prePayCargoFeeWebResponse = new PrePayCargoFeeWebResponse();
        BeanUtils.copyProperties(prePayCargoFeeResponse,prePayCargoFeeWebResponse);

        try {
            log.info("货主-确认收货-正常：{}", prePayCargoFeeWebResponse.toString());
            return YmmResponse.succResponse(prePayCargoFeeWebResponse);
        } catch (Exception e) {
            e.printStackTrace();
            log.info("货主-确认收货-正常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }


    /**
     * 司机-订单-运输中
     * @param transportOrderWebRequest
     * @return
     */
    @PostMapping(value = "driver/getOrderList")
    public YmmResponse<TransportOrderWebResponse> getTransportOrdersByDriver(@RequestBody TransportOrderWebRequest transportOrderWebRequest) {
        if(transportOrderWebRequest == null || transportOrderWebRequest.getOpenId() == null ){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
        TransportOrderRequest transportOrderRequest = new TransportOrderRequest();
        BeanUtils.copyProperties(transportOrderWebRequest, transportOrderRequest);
        try{List<TransportOrderDTO> orders = orderService.queryTransportOrdersByDriver(transportOrderRequest);

            TransportOrderWebResponse transportOrderWebResponse = new TransportOrderWebResponse();
            transportOrderWebResponse.setOrders(orders);

            log.info("司机-订单-运输中-正常：{}",orders.toString());
            return YmmResponse.succResponse(transportOrderWebResponse);
        }catch (Exception e){
            log.info("司机-订单-运输中-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }

    /**
     * 货主-订单-运输中
     * @param transportOrderWebRequest
     * @return
     */
    @PostMapping(value = "shipper/getOrderList")
    public YmmResponse<TransportOrderWebResponse> getTransportOrdersByShipper(@RequestBody TransportOrderWebRequest transportOrderWebRequest) {
        if(transportOrderWebRequest == null || transportOrderWebRequest.getOpenId() == null ){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
        TransportOrderRequest transportOrderRequest = new TransportOrderRequest();
        BeanUtils.copyProperties(transportOrderWebRequest, transportOrderRequest);

        try {
            List<TransportOrderDTO> orders = orderService.queryTransportOrdersByShipper(transportOrderRequest);


            TransportOrderWebResponse transportOrderWebResponse = new TransportOrderWebResponse();
            transportOrderWebResponse.setOrders(orders);

            log.info("货主-订单-运输中-正常：{}",orders.toString());
            return YmmResponse.succResponse(transportOrderWebResponse);
        }catch (Exception e){
            log.info("货主-订单-运输中-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }

    /**
     * 司机-订单-已取消列表
     * @param canceledOrderWebRequest
     * @return
     */
    @PostMapping(value = "driver/getCanceledOrders")
    public YmmResponse<CanceledOrderWebResponse> getCanceledOrdersByDriver(@RequestBody CanceledOrderWebRequest canceledOrderWebRequest) {
        if(canceledOrderWebRequest == null || canceledOrderWebRequest.getOpenId() == null ){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
        CanceledOrderRequest canceledOrderRequest = new CanceledOrderRequest();
        BeanUtils.copyProperties(canceledOrderWebRequest, canceledOrderRequest);
        try {
            List<CanceledOrderDTO> orders = orderService.getCanceledOrdersByDriver(canceledOrderRequest);

            CanceledOrderWebResponse canceledOrderWebResponse = new CanceledOrderWebResponse();
            canceledOrderWebResponse.setOrders(orders);

            return YmmResponse.succResponse(canceledOrderWebResponse);
        }catch (Exception e){
            log.info("司机-订单-已取消列表-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }

    /**
     * 货主-订单-已取消列表
     * @param canceledOrderWebRequest
     * @return
     */
    @PostMapping(value = "shipper/getCanceledOrders")
    public YmmResponse<CanceledOrderWebResponse> getCanceledOrdersByShipper(@RequestBody CanceledOrderWebRequest canceledOrderWebRequest) {
        if(canceledOrderWebRequest == null || canceledOrderWebRequest.getOpenId() == null ){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
        CanceledOrderRequest canceledOrderRequest = new CanceledOrderRequest();
        BeanUtils.copyProperties(canceledOrderWebRequest, canceledOrderRequest);
        try {
            List<CanceledOrderDTO> orders = orderService.getCanceledOrdersByShipper(canceledOrderRequest);

            CanceledOrderWebResponse canceledOrderWebResponse = new CanceledOrderWebResponse();
            canceledOrderWebResponse.setOrders(orders);

            return YmmResponse.succResponse(canceledOrderWebResponse);
        }catch (Exception e){
            log.error("货主-订单-已取消列表-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }

    /**
     * 司机-订单-已完成
     * @param completedOrderWebRequest
     * @return
     */
    @PostMapping(value = "driver/getCompletedOrders")
    public YmmResponse<CompletedOrderWebResponse> getCompletedOrdersByDriver(@RequestBody CompletedOrderWebRequest completedOrderWebRequest) {
        if(completedOrderWebRequest == null || completedOrderWebRequest.getOpenId() == null ){
            log.info("司机-订单-已完成-请求参数不正确：{}",completedOrderWebRequest);
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
        CompletedOrderRequest completedOrderRequest = new CompletedOrderRequest();
        BeanUtils.copyProperties(completedOrderWebRequest, completedOrderRequest);
        try {
            List<CompletedOrderDTO> orders = orderService.getCompletedOrdersByDriver(completedOrderRequest);


            CompletedOrderWebResponse completedOrderWebResponse = new CompletedOrderWebResponse();
            completedOrderWebResponse.setOrders(orders);

            return YmmResponse.succResponse(completedOrderWebResponse);
        }catch (Exception e){
            log.info("司机-订单-已完成列表-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }

    /**
     * 货主-订单-已完成
     * @param completedOrderWebRequest
     * @return
     */
    @PostMapping(value = "shipper/getCompletedOrders")
    public YmmResponse<CompletedOrderWebResponse> getCompletedOrdersByShipper(@RequestBody CompletedOrderWebRequest completedOrderWebRequest) {
        if(completedOrderWebRequest == null || completedOrderWebRequest.getOpenId() == null ){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
        CompletedOrderRequest completedOrderRequest = new CompletedOrderRequest();
        BeanUtils.copyProperties(completedOrderWebRequest, completedOrderRequest);
        try {
            List<CompletedOrderDTO> orders = orderService.getCompletedOrdersByShipper(completedOrderRequest);


            CompletedOrderWebResponse completedOrderWebResponse = new CompletedOrderWebResponse();
            completedOrderWebResponse.setOrders(orders);
            log.info("货主-订单-已完成列表-正常：{}",orders.toString());
            return YmmResponse.succResponse(completedOrderWebResponse);
        }catch (Exception e){
            log.info("货主-订单-已完成列表-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }




    /**
     * 货主-同意协议
     * @param agreeOrderWebRequest
     * @return
     */
    @PostMapping(value = "shipper/agreeOrder")
    public YmmResponse<TransportOrderWebResponse> agreeOrderByShipper(@RequestBody AgreeOrderWebRequest agreeOrderWebRequest) {
        if(agreeOrderWebRequest == null || agreeOrderWebRequest.getOpenId() == null || agreeOrderWebRequest.getOrderNumber() == null ){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
        AgreeOrderRequest agreeOrderRequest = new AgreeOrderRequest();
        BeanUtils.copyProperties(agreeOrderWebRequest, agreeOrderRequest);

        try {
            List<TransportOrderDTO> orders = orderService.agreeOrderByShipper(agreeOrderRequest);

            TransportOrderWebResponse transportOrderWebResponse = new TransportOrderWebResponse();
            transportOrderWebResponse.setOrders(orders);

            return YmmResponse.succResponse(transportOrderWebResponse);
        }catch (Exception e){
            log.info("货主-订单-同意协议-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }

    /**
     * 货主-拒绝协议
     * @param refuseOrderWebRequest
     * @return
     */
    @PostMapping(value = "shipper/refuseOrder")
    public YmmResponse<CanceledOrderWebResponse> refuseOrderByShipper(@RequestBody RefuseOrderWebRequest refuseOrderWebRequest) {
        if(refuseOrderWebRequest == null || refuseOrderWebRequest.getOpenId() == null || refuseOrderWebRequest.getOrderNumber() == null ){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
        RefuseOrderRequest refuseOrderRequest = new RefuseOrderRequest();
        BeanUtils.copyProperties(refuseOrderWebRequest, refuseOrderRequest);

        try {
            List<CanceledOrderDTO> orders = orderService.refuseOrderByShipper(refuseOrderRequest);

            CanceledOrderWebResponse canceledOrderWebResponse = new CanceledOrderWebResponse();
            canceledOrderWebResponse.setOrders(orders);

            return YmmResponse.succResponse(canceledOrderWebResponse);
        }catch (Exception e){
            log.info("货主-订单-拒绝协议-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }

    /**
     * 货主-取消订单
     * @param cancelOrderWebRequest
     * @return
     */
    @PostMapping(value = "shipper/cancelOrder")
    public YmmResponse<CanceledOrderWebResponse> cancelOrderByShipper(@RequestBody CancelOrderWebRequest cancelOrderWebRequest) {
        if(cancelOrderWebRequest == null || cancelOrderWebRequest.getOpenId() == null || cancelOrderWebRequest.getOrderNumber() == null ){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
        CancelOrderRequest cancelOrderRequest = new CancelOrderRequest();
        BeanUtils.copyProperties(cancelOrderWebRequest, cancelOrderRequest);

        try {
            List<CanceledOrderDTO> orders = orderService.cancelOrderByShipper(cancelOrderRequest);

            CanceledOrderWebResponse canceledOrderWebResponse = new CanceledOrderWebResponse();
            canceledOrderWebResponse.setOrders(orders);

            log.info("货主-订单-取消订单-正常：{}",orders.toString());
            return YmmResponse.succResponse(canceledOrderWebResponse);
        }catch (Exception e){
            log.info("货主-订单-取消订单-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }

//    /**
//     * 货主-确认收货
//     * @param receiveOrderWebRequest
//     * @return
//     */
//    @PostMapping(value = "shipper/receiveOrder")
//    public YmmResponse<CompletedOrderWebResponse> receiveOrderByShipper(@RequestBody ReceiveOrderWebRequest receiveOrderWebRequest) {
//        if(receiveOrderWebRequest == null || receiveOrderWebRequest.getOpenId() == null || receiveOrderWebRequest.getOrderNumber() == null ){
//            log.info("请求参数不正确");
//            return YmmResponse.failResponse(1,"请求参数不正确");
//        }
//        ReceiveOrderRequest receiveOrderRequest = new ReceiveOrderRequest();
//        BeanUtils.copyProperties(receiveOrderWebRequest, receiveOrderRequest);
//
//        try {
//            List<CompletedOrderDTO> orders = orderService.receiveOrderByShipper(receiveOrderRequest);
//
//            CompletedOrderWebResponse completedOrderWebResponse = new CompletedOrderWebResponse();
//            completedOrderWebResponse.setOrders(orders);
//
//            log.info("货主-订单-确认收货-正常：{}",orders.toString());
//            return YmmResponse.succResponse(completedOrderWebResponse);
//        }catch (Exception e){
//            log.info("货主-订单-确认收货-异常：{}",e.toString());
//            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
//        }
//    }

    /**
     * 货主-重新上架
     * @param republishCargoWebRequest
     * @return
     */
    @PostMapping(value = "shipper/republishCargo")
    public YmmResponse<RepublishCargoWebResponse> republishCargoByShipper(@RequestBody RepublishCargoWebRequest republishCargoWebRequest) {
        if(republishCargoWebRequest == null || republishCargoWebRequest.getOpenId() == null){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
            RepublishCargoRequest republishCargoRequest = new RepublishCargoRequest();
            BeanUtils.copyProperties(republishCargoWebRequest, republishCargoRequest);

        try {
            CargoInfoDTO cargo = orderService.republishCargo(republishCargoRequest);
            RepublishCargoWebResponse republishCargoWebResponse = new RepublishCargoWebResponse();
            BeanUtils.copyProperties(cargo,republishCargoWebResponse);
            republishCargoWebResponse.setCargoInfo(cargo);

            log.info("货主-订单-重新上架-正常：{}",republishCargoWebResponse.toString());
            return YmmResponse.succResponse(republishCargoWebResponse);
        }catch (Exception e){
            log.info("货主-订单-重新上架-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }





    /**
     * 司机-取消订单
     * @param cancelOrderWebRequest
     * @return
     */
    @PostMapping(value = "driver/cancelOrder")
    public YmmResponse<CanceledOrderWebResponse> cancelOrderByDriver(@RequestBody CancelOrderWebRequest cancelOrderWebRequest) {
        if(cancelOrderWebRequest == null || cancelOrderWebRequest.getOpenId() == null || cancelOrderWebRequest.getOrderNumber() == null ){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
        CancelOrderRequest cancelOrderRequest = new CancelOrderRequest();
        BeanUtils.copyProperties(cancelOrderWebRequest, cancelOrderRequest);

        try {
            List<CanceledOrderDTO> orders = orderService.cancelOrderByDriver(cancelOrderRequest);

            CanceledOrderWebResponse canceledOrderWebResponse = new CanceledOrderWebResponse();
            canceledOrderWebResponse.setOrders(orders);
            log.info("司机-取消订单-正常：{}",orders.toString());
            return YmmResponse.succResponse(canceledOrderWebResponse);
        }catch (Exception e){
            log.info("司机-取消订单-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }


    /**
     * 司机-我已装货
     * @param loadOrderWebRequest
     * @return
     */
    @PostMapping(value = "driver/loadOrder")
    public YmmResponse<TransportOrderWebResponse> loadOrderByDriver(@RequestBody LoadOrderWebRequest loadOrderWebRequest) {
        if(loadOrderWebRequest == null || loadOrderWebRequest.getOpenId() == null || loadOrderWebRequest.getOrderNumber() == null ){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
        LoadOrderRequest loadOrderRequest = new LoadOrderRequest();
        BeanUtils.copyProperties(loadOrderWebRequest, loadOrderRequest);

        try {
            List<TransportOrderDTO> orders = orderService.loadOrderByDriver(loadOrderRequest);

            TransportOrderWebResponse transportOrderWebResponse = new TransportOrderWebResponse();
            transportOrderWebResponse.setOrders(orders);
            log.info("司机-我已装货-正常：{}",orders.toString());
            return YmmResponse.succResponse(transportOrderWebResponse);
        }catch (Exception e){
            log.info("司机-我已装货-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }



    /**
     * 司机-我已卸货
     * @param unloadOrderWebRequest
     * @return
     */
    @PostMapping(value = "driver/unloadOrder")
    public YmmResponse<TransportOrderWebResponse> unloadOrderByDriver(@RequestBody UnloadOrderWebRequest unloadOrderWebRequest) {
        if(unloadOrderWebRequest == null || unloadOrderWebRequest.getOpenId() == null || unloadOrderWebRequest.getOrderNumber() == null ){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }
        UnloadOrderRequest unloadOrderRequest = new UnloadOrderRequest();
        BeanUtils.copyProperties(unloadOrderWebRequest, unloadOrderRequest);

        try {
            List<TransportOrderDTO> orders = orderService.unloadOrderByDriver(unloadOrderRequest);

            TransportOrderWebResponse transportOrderWebResponse = new TransportOrderWebResponse();
            transportOrderWebResponse.setOrders(orders);
            log.info("司机-我已卸货-正常：{}",orders.toString());
            return YmmResponse.succResponse(transportOrderWebResponse);
        }catch (Exception e){
            log.info("司机-我已卸货-异常：{}",e.toString());
            return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
        }
    }


    /**
     * 司机评价货主
     * @param appraiseWebRequest
     * @return
     */
    @PostMapping(value = "driver/appraiseShipper")
    public AppraiseOrderWebResponse payDepositByDriver(@RequestBody AppraiseOrderWebRequest appraiseWebRequest) {


        return null;
    }

    @PostMapping(value = "shipper/coldMembership/getTruckData")
    public YmmResponse<ColdTruckWebResponse> getColdTruckDataByShipper(@RequestBody ColdTruckWebRequest coldTruckWebRequest){
        if(coldTruckWebRequest == null || coldTruckWebRequest.getOpenId() == null || coldTruckWebRequest.getOrderNumber() == null ){
            log.info("请求参数不正确");
            return YmmResponse.failResponse(1,"请求参数不正确");
        }

        ColdTruckRequest coldTruckRequest = new ColdTruckRequest();
        BeanUtils.copyProperties(coldTruckWebRequest,coldTruckRequest);

       try {
           ColdTruckResponse coldTruckResponse = orderService.getColdTruckDataByShipper(coldTruckRequest);

           ColdTruckWebResponse coldTruckWebResponse = new ColdTruckWebResponse();

           BeanUtils.copyProperties(coldTruckResponse, coldTruckWebResponse);

           log.info("冷链司机-货车温湿度-正常：{}", coldTruckWebResponse.toString());
           return YmmResponse.succResponse(coldTruckWebResponse);
       }catch (Exception e){
           log.info("冷链司机-货车温湿度-异常：{}",e.toString());
           return YmmResponse.failResponse(0,"系统繁忙，请稍后重试");
       }
    }

}
